
import {useState,useDeferredValue} from "react";
import SlowPast from "./SlowPast";


export default function Input(){
    const [value, setValue] = useState("");

    //使用useDeferredValue来延迟更新value，使得输入框的更新更平滑
    const deferredValue = useDeferredValue(value);
    console.log("value:",deferredValue);
    console.log("value:",value);
    return (
        <>
            <input value={value} onChange={(e) => {
                setValue(e.target.value);
            }} />
            <SlowPast value={deferredValue} />
        </>
    )
}


